package com.shareach.domain;

import java.util.Arrays;
import java.util.Date;

import org.apache.commons.lang.StringUtils;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;

import com.shareach.domain.common.Entity;

/**
 * 团购商家
 * 
 * @author zuoshuaiok@gmail.com
 * 
 *         2013-1-28
 */
@Document(collection = "bizTuanShop")
public class BizTuanShopDomain extends Entity {
	// 团购标识[团购基础数据 的 _id]
	private Long tuanId;
	// 来源网站[参见 来源网站 BaseSite]
	private String site;
	// 来源网站id
	private String siteId;
	// 连锁品牌名
	private String brandName;

	// 商家名称
	private String name;

	// 采集的名称'[全名]
	private String orgName;
	// /地址
	private String addr;
	// 商家[如果未绑定，则为空，商家]
	private Long shopId;
	// 电话数
	private String[] tels;
	//
	private Float same;
	//
	private Long city;
	// 匹配时间
	private Date matchTime;
	// 更新时间或者创建时间
	private Date updateTime = new Date();
	// 上架时间
	private Date deployTime;
	// 创建时间
	private Date creatTime;
	@Transient
	private BaseShopDomain baseShop;

	// 状态
	private Integer status;

	public BaseShopDomain getBaseShop() {
		return baseShop;
	}

	public void setBaseShop(BaseShopDomain baseShop) {
		this.baseShop = baseShop;
	}

	public Date getCreatTime() {
		return creatTime;
	}

	public void setCreatTime(Date creatTime) {
		this.creatTime = creatTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public Date getDeployTime() {
		return deployTime;
	}

	public void setDeployTime(Date deployTime) {
		this.deployTime = deployTime;
	}

	public Date getMatchTime() {
		return matchTime;
	}

	public void setMatchTime(Date matchTime) {
		this.matchTime = matchTime;
	}

	public String getAddr() {
		return addr;
	}

	public String getBrandName() {
		return brandName;
	}

	public String getName() {
		return name;
	}

	public String getOrgName() {
		return orgName;
	}

	public Float getSame() {
		return same;
	}

	public Long getShopId() {
		return shopId;
	}

	public String getSite() {
		return site;
	}

	public String getSiteId() {
		return siteId;
	}

	public String[] getTels() {
		return tels;
	}

	public Long getTuanId() {
		return tuanId;
	}

	public void setAddr(String addr) {
		this.addr = addr;
	}

	public void setBrandName(String brandName) {
		this.brandName = brandName;
	}

	public Long getCity() {
		return city;
	}

	public void setCity(Long city) {
		this.city = city;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}

	public void setSame(Float same) {
		this.same = same;
	}

	public void setShopId(Long shopId) {
		this.shopId = shopId;
	}

	public void setSite(String site) {
		this.site = site;
	}

	public void setSiteId(String siteId) {
		this.siteId = siteId;
	}

	public void setTels(String[] tels) {
		this.tels = tels;
	}

	public void setTuanId(Long tuanId) {
		this.tuanId = tuanId;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public BizTuanShopDomain compareTo(BizTuanShopDomain domain) {
		BizTuanShopDomain change = new BizTuanShopDomain();
		if (null == domain) {
			return change;
		}
		if (StringUtils.isNotEmpty(domain.getOrgName())) {
			if (this.orgName == null || !this.orgName.trim().equals(domain.getOrgName().trim())) {
				change.setOrgName(domain.getOrgName().trim());
			}
		}
		if (domain.getShopId() != null) {
			if (this.shopId == null || !this.shopId.equals(domain.getShopId())) {
				change.setShopId(domain.getShopId());
			}
		}
		if (domain.getTels() != null && domain.getTels().length > 0) {
			if (this.tels == null || !Arrays.equals(this.tels, domain.getTels())) {
				change.setTels(domain.getTels());
			}
		}
		if (domain.getStatus() != null) {
			if (this.status == null || !domain.getStatus().equals(this.status)) {
				change.setStatus(domain.getStatus());
			}
		}
		return change;
	}
}
